home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
PlayerPRO 4.4.1
/
MADF Library 3.0
/
RDriver.h
< prev
next >
Wrap
Text File
|
1995-04-07
|
9KB
|
320 lines
/******************** ***********************/
//
// Player PRO 4.4x -- MAD Music Driver Definition
//
// Library Version 3.0
//
// To use with MusicLibrary for Think C & CodeWarrior
//
// Antoine ROSSET
// 16 Tranchees
// 1206 GENEVA
// SWITZERLAND
//
// FAX: (+41 22) 346 11 97
// Compuserve: 100277,164
// Internet: rosset@dial.eunet.ch
//
/******************** ***********************/
#define MAX_ARP 3
#define NUMBER_FINETUNES 16
#define NUMBER_NOTES 84
#define AMIGA_CLOCKFREQ2 3575872L
#define MIN_PITCH 13L
#define MAX_PITCH 1918L
#define MIN_VOLUME 0
#define MAX_VOLUME 64
#define MAXTRACK 32
#define MAXINSTRU 64
#define MAXPATTERN 200
#define MAXPATTERNSIZE 1024
/******************** ***********************/
/*** RInit Function parameter ***/
/******************** ***********************/
enum
{
ASCSoundDriver = 1,
AWACSoundDriver,
MIDISoundDriver,
SoundManagerDriver
};
enum
{
MonoOutPut = 1,
StereoOutPut,
TrueStereoOutPut
};
struct RInitDesc
{
short TrackNo; // from 2 to 32
short OutPutBits; // 8 or 16
long OutPutFrequency; // rate44khz, rate22050hz, rate22khz, rate11khz, rate11025hz
short DriverMode; // ASCSoundDriver, AWACSoundDriver, MIDISoundDriver or SoundManagerDriver
short SMBufferSize; // Used only if DriverMode == SoundManagerDriver
short VExt; // Play Speed : 80 = normal
short FreqExt; // Play Pitch : 80 = normal
Boolean AntiAliasing; // Use AntiAliasing filter ?
short OutPutMode; // Mono, Stereo or True Stereo output ?
Boolean RepeatMusic; // If music finished, repeat it or stop.
};
typedef struct RInitDesc RInitDesc;
/******************** ***********************/
/*** Voice structure definition ***/
/******************** ***********************/
struct VoiceActive {
Ptr MaxPtr;
Ptr InstruVoice;
Ptr StartPtr;
long loopWord;
long loopWords;
short Instru;
short InstruOld;
short fineTune;
short Amiga;
short AmigaOld;
short pitch;
short realpitch;
short Prerealpitch;
short volume;
short effect;
Byte arg;
short arp[MAX_ARP];
short arpindex;
short viboffset;
short vibdepth;
short slide;
short pitchgoal;
short pitchrate;
short oldpitchrate;
short volumerate;
short vibrate;
short oldvibrate;
short retrig;
short ID;
short amplitude;
Ptr samplePtr;
Boolean repeat;
};
typedef struct VoiceActive VoiceActive;
/******************** ***********************/
/*** Music description used in driver ***/
/******************** ***********************/
struct MADPartition
{
MADSpec* header;
struct MusicPattern* partition[ MAXPATTERN];
Ptr instrument[ MAXINSTRU];
};
typedef struct MADPartition MADPartition;
/******************** ***********************/
/*** PlayerPRO variables ***/
/******************** ***********************/
#ifdef MainSystemPlayerPRO
#define EXTDR
#else
#define EXTDR extern
#endif
#ifndef __SOUND__
#include <Sound.h>
#endif
EXTDR RInitDesc InitDescInt;
EXTDR MADPartition thePartition; // Current music in memory, loaded with RLoadMusic() by example
EXTDR MADSpec *theFileInt; // Current music header == thePartition.header
EXTDR VoiceActive theVoiceActive[ MAXTRACK]; // Current driver voices
EXTDR short DriverTypeInt; // Actual driver type
EXTDR short Tube[ MAXTRACK]; // Used in 'Tracks View' Window - View menu
EXTDR short PartitionReader; // Current position in pattern (0...64)
EXTDR short Pat; // Current ID Pattern, see 'Patterns list'
EXTDR short PL; // Current position in partition, see 'Partition list'
EXTDR short VolExt[ MAXTRACK]; // Volumes settings, see 'Adaptators' window
EXTDR short speed; // Current speed, see speed Effect
EXTDR short finespeed; // Current finespeed, see speed Effect
EXTDR short InstruTube[ MAXINSTRU]; // Used in 'Instrument View' Window - View menu
EXTDR short VExt; // External music speed, see 'Adaptators' window
EXTDR short FreqExt; // External music pitch, see 'Adaptators' window
EXTDR short DriveTrackNo; // Actual number of tracks
EXTDR short DriveOutBit; // Output bit: 8 or 16 bits
EXTDR Boolean PtrSystem; // Use NewPtr or NewPtrSys ?
EXTDR Boolean Reading; // Reading indicator
EXTDR Boolean MusiqueFertig; // Is your music finished?
EXTDR Boolean AntiAliasingFilter; // Is AntiAliasingFilter On? RInitMusic turns it to false
EXTDR short LeftRight[ MAXTRACK]; // Left/Right % for Deluxe Driver
/* DO NOT MODIFY OR USE these variables */
EXTDR short smallcounter, trackDiv;
EXTDR long ASCBUFFER, FREQBASE;
EXTDR short **FreqHandle, InstruActif[ MAXINSTRU];
EXTDR Ptr SysHeapPtr, Vol, IntDataPtr, OscilloWavePtr;
EXTDR Boolean RepeatMusic, JumpToNextPattern;
EXTDR Boolean DriveStereo, PtrSystem, JumpToNextPattern, AntiAliasing;
EXTDR short pitchTable[ NUMBER_NOTES + 4][ NUMBER_FINETUNES];
EXTDR long VSYNC, BufCounter, BytesToGenerate;
extern short vibrato_table[ ];
/******************** ***********************/
/*** DRIVERS ID ***/
/*** DO NOT USE MIDIClassic Driver !!!! ***/
/******************** ***********************/
enum {
ASCMono = 1,
ASCStereo = 2,
SMMono = 3,
SMStereo = 4,
SMDSP = 5,
SMPolyPhonic = 6,
MIDIClassic = 7,
AWAC = 8,
SMDELUXE = 9,
SMDELUXE8 = 10
};
/******************** ***********************/
/*** EFFECTS ID ***/
/******************** ***********************/
enum {
arpeggioE = 0,
downslideE = 1,
upslideE = 2,
portamentoE = 3,
vibratoE = 4,
portaslideE = 5,
vibratoslideE = 6,
nothingE = 7,
offsetE = 9,
slidevolE = 10,
fastskipE = 11,
volumeE = 12,
skipE = 13,
extendedE = 14,
speedE = 15
};
/******************** ***********************/
/* General Function Description */
/* For more informations about these functions, e-mail me */
/******************** ***********************/
/******************** ***********************/
/*** EXTERNAL ROUTINES ***/
/*** See Documentation for more informations on these routines ***/
/******************** ***********************/
enum {
FileType = 1,
RsrcType = 2,
PtrType = 3
};
#ifdef __cplusplus
extern "C" {
#endif
OSErr RInitMusic( short, short, Boolean); // Music Driver initialization
OSErr RPlayMusic( void); // Play the current music
OSErr RStopMusic( void); // Stop the current music
OSErr RResetMusic( void); // Reset the current music at the start position
OSErr RQuitMusic( void); // Dispose the music driver, use it after RInitMusic()
OSErr RLoadMusic( Str255 fName); // Load a MAD File in the current directory
OSErr RLoadMusicRsrc( OSType IDName, short IDNo); // Load a MAD Rsrc into memory
OSErr RLoadMusicPtr( Ptr myPtr); // Load a MAD Ptr into memory, you can DisposPtr your Ptr after this call
OSErr RInstallMADF( MADPartition aPartition); // Install directly a MAD partition
OSErr RClearMusic(void); // Dispose the current music, use it after RLoadMusic(), RLoadMusicRsrc(), RInstallMADF()
OSErr ConvertMod2Mad( Ptr aMOD, long Size, MADPartition *theMAD); // Convert MOD to MAD
Ptr ConvertMad2Mod( MADPartition *theMAD); // Convert MAD to MOD
void ChangeTrackNo( short); // Change current tracks number of the music driver
void CleanDriver(); // Clean the driver
struct Command* GetCommand( short PosX, short TrackIdX, struct MusicPattern* tempMusicPat); // Extract a Command from a MusicPattern
// Play a sound with an amplitude on a track at a period, with loopStart and loopEnd
// If period == 0, play it at normal frequence 22Khz ( F#5 )
// Period: from 0 to NUMBER_NOTES
OSErr RPlaySound( Ptr whichSound, long SoundSize, long whichTrack, long Period, long Amplitude, long loopStart, long loopLength);
/******************** ***********************/
/*** INTERNAL ROUTINES ***/
/*** DO NOT use these routines ***/
/******************** ***********************/
void Sampler8in8Add( VoiceActive *curVoice, register Ptr ASCBuffer);
void Sampler16Add( VoiceActive *curVoice, register short *ASCBuffer);
void NoteAnalyse( void);
void ClearVol4();
OSErr SetUpFrequence( long, long);
OSErr ReadInstrument( short, short, Handle, Ptr);
void DoEffect( VoiceActive *, short);
OSErr DBSndClose();
void StopChannel();
OSErr SetMODVol4( long , long , Boolean );
void PlayChannel();
void checkpitch( VoiceActive *, Boolean);
void BufferCopyM();
void BufferCopyS();
void InstallMODVBL(void);
void ReadNote( VoiceActive *curVoice, struct Command *theCommand);
void RemoveMODVBL(void);
void MODRelance(void);
void Play(void);
void VIAOn(void);
void SndOff(void);
void SndOn(void);
void VIAOn2(void);
void VIAOn3(void);
OSErr InitDBSoundManager( long);
void SetUpEffect( VoiceActive *ch);
Boolean DirectSave( Ptr, short, short);
void ChangeSpeed( void);
void Play16Stereo( void);
void Play8Stereo( void);
void Play8Mono( void);
void ClearFrequence();
#ifdef __cplusplus
}
#endif